import React, {useEffect, useState} from 'react'
import BatchUpload from '@/components/BatchUpload'
import {
	getExclclue,
	postExcclue,
	getDataclue,
} from '@/service/merchantCenter/clue'

function ExportExcl(props: any) {
	const {info, sunchange, getData} = props
	const [importDriverId, setImportDriverId] = useState(false) // 导入线索列表
	useEffect(() => {
		setImportDriverId(info)
	}, [info])
	const childCange = (value: any) => {
		if (sunchange) {
			sunchange(value)
		}
	}
	const column = [
		{
			title: '线索名称',
			dataIndex: 'username',
			align: 'center',
			key: 'username',
			width: 100,
		},
		{
			title: '线索手机号',
			dataIndex: 'phone',
			align: 'center',
			key: 'phone',
			width: 100,
		},
		{
			title: '来源',
			dataIndex: 'sourceName',
			align: 'center',
			key: 'sourceName',
			width: 100,
		},
		{
			title: '所属主体',
			dataIndex: 'subjectName',
			align: 'center',
			key: 'subjectName',
			width: 100,
		},
		{
			title: '所属公司',
			dataIndex: 'orgName',
			align: 'center',
			key: 'orgName',
			width: 100,
		},
		{
			title: '城市',
			dataIndex: 'cityName',
			align: 'center',
			key: 'cityName',
			width: 100,
		},
		{
			title: '失败原因',
			dataIndex: 'reason',
			align: 'center',
			key: 'reason',
			width: 200,
			fixed: 'right',
		},
	]
	return (
		<BatchUpload
			isModalOpen={importDriverId}
			setIsModalOpen={setImportDriverId}
			importData={getExclclue} // 导入接口
			onTableList={getDataclue} // 获取列表数据-失败
			getListData={() => getData({})} // 获取列表数据-成功
			columns={column}
			sourceId={44}
			templateType="线索管理导入模板"
			uploadFileUrl={postExcclue} // 文件上传接口
			title="导入线索列表"
			childCange={childCange}
			width={800}
			clue="1"
		/>
	)
}

export default ExportExcl
